﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace QuanLyGiaoVuDAL.DTO
{
    public class LopMonHocDTO
    {
        public System.Guid LopMonHocId { get; set; }

        public String MaLopMonHoc { get; set; }

        public System.Guid MaMonHoc { get; set; }

        public System.Guid MaGiangVien1 { get; set; }

        public System.Guid? MaGiangVien2 { get; set; }

        public System.Guid MaHocKy { get; set; }

        public int? MaTietDau { get; set; }

        public int? MaTietSau { get; set; }

        public short Thu { get; set; }

        public System.Nullable<System.Guid> MaPhong { get; set; }

        public int? SiSoToiDa { get; set; }

        public int? SiSoThucTe { get; set; }

        public int LoaiLop { get; set; }

        public short TyLeDiem { get; set; }

        public System.Nullable<System.Guid> MaLopChinh { get; set; }

        public Guid? LopSinhVienId { get; set; }

        public bool GiangVienXacNhan { get; set; }

        public bool DaPhanHoi { get; set; }

        public String GhiChu { get; set; }

        public bool DongYMoLop { get; set; }

        public string Phong { get; set; }

        public int ThuTuTrongTuan { get; set; }

        public MonHocDTO MonHoc { get; set; }

        public GiangVienDTO GiangVien1 { get; set; }

        public GiangVienDTO GiangVien2 { get; set; }

        public HocKyDTO HocKy { get; set; }

        public TietHocDTO TietDau { get; set; }

        public TietHocDTO TietSau { get; set; }

        public LopMonHocDTO LopChinh{get; set; }

        public LopSinhVienDTO LopSinhVien { get; set; }

        //public LichThiDTO LichThi { get; set; }

        public String MaLopDayDu
        {
            get
            {
                try
                {
                    return MonHoc.MaMonHoc.Trim() + "." + MaLopMonHoc;
                }
                catch
                {
                    return String.Empty;
                }
            }
        }

        public String MaLopVaTenMonHoc
        {
            get
            {
                return MonHoc.MaMonHoc.Trim() + "." +  MaLopMonHoc + " - " + MonHoc.TenMonHoc;
            }
        }

        public int Bac { get; set; }

        public int ThuTuXepLich { get; set; }

        public IList<int> DanhSachKhaNang { get; set; }

        public bool DaXet { get; set; }

        public int KhaNangDuocChon { get; set; }

        public DateTime? Buoi1 { get; set; }

        public DateTime? Buoi2 { get; set; }

        public DateTime? Buoi3 { get; set; }

        public String TietDayString {
            get {
                string result = string.Empty;
                try
                {
                    int tietDau = TietDau.TietThu;
                    int tietSau = TietSau.TietThu;
                    for (int tiet = tietDau; tiet <= tietSau; tiet++)
                        result += tiet.ToString();
                    return result;
                }
                catch (Exception exception)
                {
                    return string.Empty;
                }
            }
        }

        public String KhaNangDuocChonString
        {
            get
            {
                int khaNang;
                try
                {
                    khaNang = (Thu - 2) * 4;
                    if (TietDau.TietThu >= 1 && TietDau.TietThu <= 3)
                        khaNang += 1;
                    else
                        if (TietDau.TietThu >= 4 && TietDau.TietThu <= 5)
                            khaNang += 2;
                        else
                            if (TietDau.TietThu >= 6 && TietDau.TietThu <= 7)
                                khaNang += 3;
                            else if (TietDau.TietThu >= 8)
                                khaNang += 4;
                }
                catch
                {
                    khaNang = -1;
                }
                return khaNang > -1 ? khaNang.ToString() : String.Empty;
            }
        }
    }
}